<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>新增</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="/assets/layui/css/layui.css"  media="all">
  <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
  <legend>新增</legend>
</fieldset>
<form class="layui-form layui-form-pane" action="save">
  <input type="hidden" name=".table" value="#(table)" />
  #for(c : cols)
        	#if(c.column_name=="id")
        	#elseif(c.column_name=="add_time"||c.column_name=="update_time"||c.column_name=="opby")
        	#elseif(c.data_type=="timestamp"||c.data_type=="datetime"||c.data_type=="date")
  <div class="layui-form-item">
    <div class="layui-inline">
      <label class="layui-form-label">#(c.column_comment)</label>
      <div class="layui-input-block">
        <input type="text" name="#(c.column_name)" autocomplete="off" class="date layui-input">
      </div>
    </div>
  </div>
  #elseif(c.data_type=="text")
  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">#(c.column_comment)</label>
    <div class="layui-input-block">
      <textarea name="#(c.column_name)" placeholder="填写#(c.column_comment)" class="layui-textarea"></textarea>
    </div>
  </div>
  #elseif(c.column_name=="json")
  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">#(c.column_comment)</label>
    <div class="layui-input-block">
      <textarea name="#(c.column_name)" placeholder="Json格式数据" class="layui-textarea"></textarea>
    </div>
  </div>
  #else
  <div class="layui-form-item">
    <label class="layui-form-label">#(c.column_comment)</label>
    <div class="layui-input-inline">
      <input type="text" name="#(c.column_name)" lay-verify="required" placeholder="填写#(c.column_comment)" autocomplete="off" class="layui-input">
    </div>
  </div>
  #end
  #end
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>
          
<script src="/assets/layui/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 --> 
 
<script>
layui.use(['form', 'layedit', 'laydate'], function(){
	  var form = layui.form
	  ,layer = layui.layer
	  ,layedit = layui.layedit
	  ,laydate = layui.laydate;
	  
	  //日期
	  laydate.render({
	    elem: '.date'
	  });
	  
	  //创建一个编辑器
	  var editIndex = layedit.build('LAY_demo_editor');
	 
	  //自定义验证规则
	  form.verify({
	    title: function(value){
	      if(value.length < 5){
	        return '标题至少得5个字符啊';
	      }
	    }
	    ,pass: [/(.+){6,12}$/, '密码必须6到12位']
	    ,content: function(value){
	      layedit.sync(editIndex);
	    }
	  });
	  
	  //监听提交
	  form.on('submit(demo1)', function(data){
	    layer.alert(JSON.stringify(data.field), {
	      title: '最终的提交信息'
	    })
	    return false;
	  });
	 
	});
</script>

</body>
</html>